define(function (require) {
var zsApp= require('app');  
zsApp.controller('storageController', ['$scope', '$http', '$timeout', 'selectCache','$interval', function($scope, $http, $timeout, selectCache,$interval) {
	$scope.storagedate = [];
	
	$scope.tabVal = [];
	// pagination
	$scope.paginationConf = {
        currentPage     : 1,
        totalItems      : 100,
        itemsPerPage    : 10,
        pagesLength     : 15,
        perPageOptions  : [10, 20, 30, 40, 50],
        onChange: function() { 
        	var self = this,
	        	pagingData = {
	        		pageNumber  : self.currentPage,  
					pageSize 	: self.itemsPerPage,  
	        	};	
			$http({
				url  	: 'http://localhost:8080/digitalhome-import-data/inventoryStatus/queryAll.do',
				method 	: 'POST',
				data 	:  {
                    pageNumber  : self.currentPage,  
                    pageSize    : self.itemsPerPage,  
                    resourcetype : $scope.resourcetype||'',
                    importtype : $scope.importtype||'',
                    inventorystatus : $scope.inventorystatus||'',
                    auditstatus : $scope.auditstatus||'',
                    startDate : $scope.startDate||'',
                    endDate : $scope.endDate||'',
                }

			}).success(function(res) { 

                $scope.tabVal = res;
                
                $scope.resTypeList = [{'id':'期刊','name':'期刊'},{'id':'资源','name':'资源'}];
                
                $scope.importList = [{'id':'xml','name':'xml'},{'id':'xsl','name':'xsl'}];
                
                $scope.inventorysList = [{'id':'未入库','name':'未入库'},{'id':'已入库','name':'已入库'},{'id':'待入库','name':'待入库'}];
                
                $scope.auditList = [{'id':'未审核','name':'未审核'},{'id':'已审核','name':'已审核'},{'id':'待审核','name':'待审核'}];

                // 系统配置键列表页面表格
                //$scope.tabVal = res.result;
                angular.forEach($scope.tabVal, function(obj, i) {
                    // 遍历每条数据对应的ID
                    $scope.dataID[i]   = obj.resTypeId;
                });
                // 总共有多少条数据
                self.totalItems = res.length;
            }).error(function(err) {
            	
            });
        }
    };
	
	
	// 检索（第二页，弹窗）（新增、修改复用）
    ;(function() {
    	
    	 // 资源分类（下拉框）
        $scope.getSelectId = function() {
            console.log(this.resourcetype);
            
            if(this.resourcetype=="期刊"){
            	
            	$("#magazine").css("display","block");
            	
            	
            	
            	$("#resource").css("display","none");
            	
            	
            }else if(this.resourcetype=="资源"){
            	
            	$("#resource").css("display","block");
            	
            	
            	
            	$("#magazine").css("display","none");
            }else{
            	
            	
            	$("#magazine").css("display","none");
            	
            	$("#resource").css("display","none");
            	
            }
        };
        
        // 检索（搜索框）
        $scope.searchBtn = function() {
            // console.log($scope.newlyAddedListSearch);
            $scope.paginationConf.onChange();
        };
    })();
    
    
    

    
    $scope.fnImport = function(resourcetypes) {
    	
    	
    	//alert($scope.resourcetype+'->'+$scope.importtype+'->'+$scope.resourceFileUrl);
    	
    	if(resourcetypes=="期刊"){ 
    		
    		alert("期刊");
    		
    		$http({
				url  	: 'http://localhost:8080/digitalhome-import-data/magazine/libraryXml.do',
				method 	: 'POST',
				data 	:  { 
                    resourcetypes : $scope.resourcetypes,
                    importtypes : $scope.importtypes,
                    filePath:$scope.resourceFileUrl,
                    
                }

			}).success(function(res) { 

               
            }).error(function(err) {
            	
            });
    		
    		
    	}else if(resourcetypes=="资源"){
    		
    		
    		$http({
				url  	: 'http://localhost:8080/digitalhome-import-data/resource/library.do',
				method 	: 'POST',
				data 	:  {  
                    resourcetypes : $scope.resourcetypes||'',
                    importtypes : $scope.importtypes||'',
                    filePath:$scope.resourceFileUrl||'',
                   
                }

			}).success(function(res) { 

              
            }).error(function(err) {
            	
            });
    		
    		
    	}
    	
    	
    	
    	
    };
	
    //add
     $scope.add = function(){
    	$("#add").modal("show");
    	$scope.storagesh = false;
    	$scope.storagetime = 1;
    	$scope.storagethree = false;
    	$scope.storagedate =[
                	{
						storageName:'资源名称1',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称2',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称3',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称4',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称fa',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称6',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
                ]
    }	
    
    //storage
    $scope.storage = function(){
    	$("#storage").modal("show");
    	$scope.storagedate =[
                	{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
  					{
						storageName:'资源名称',
						storageType:'视频',
						storageFormat:'XML',
						storageSource:'FAFA.MP4',
						storageInput:'e:admin',
						storageFictitious:'d:test',
						storageScreenshot:'gpg',
  					},
                ]
    }	
    
    //details
     $scope.details = function($index){
    	$("#details").modal("show");
    	$scope.tabValdetails = { 
    		resourcename			:$scope.tabVal[$index].resourcename,
    		resourcetype			:$scope.tabVal[$index].resourcetype,
    		importtype		:$scope.tabVal[$index].importtype,
    		sourcedatafilename		:$scope.tabVal[$index].sourcedatafilename,
    		objectfilename		:$scope.tabVal[$index].objectfilename,
    		virtualdirectory	:$scope.tabVal[$index].virtualdirectory,
    		createdatatime			:$scope.tabVal[$index].createdatatime,
    		auditstatus		:$scope.tabVal[$index].auditstatus,
    		inventorystatus		:$scope.tabVal[$index].inventorystatus,
    	}
    	console.log($scope.tabValdetails)
    }	
    
    //storagenext
    $scope.progress=0;
    $scope.storagesh = false;
    $scope.storagenext = function(){
    	$scope.storageone = false;
    	$scope.storagesh = true;
    	$scope.progress=10;
    	$scope.storagetime = 2;
    	
	    $scope.test = $interval(function () {
            $scope.progress += 1;
            if($scope.progress>100){
    			$scope.progress=100;
    			$scope.storagetime = 3;
    			$scope.storagethree = true;
    			$interval.cancel($scope.test);
	    	}
		    if($scope.progress<0){
	    		$scope.progress=0;
	    	}
        }, 100);
    }
    
    //storagestep
    $scope.storagestep = function(){
    	$scope.storagesh = false;
    	$scope.storagetime = 1;
    	$scope.storagethree = false;
    }
}])   
.directive('storageAdd', function() {
	return {
		restrict	: 'E',
		templateUrl : 'product/storage/add.html',
		replace		: true,	
	}
})
});